.TH std::span::rbegin,std::span::crbegin 3 "2024.06.10" "http://cppreference.com" "C++ Standard Libary"
.SH NAME
std::span::rbegin,std::span::crbegin \- std::span::rbegin,std::span::crbegin

.SH Synopsis
   constexpr reverse_iterator rbegin() const noexcept;        \fB(1)\fP \fI(since C++20)\fP
   constexpr const_reverse_iterator crbegin() const noexcept; \fB(2)\fP (since C++23)

   Returns a reverse iterator to the first element of the reversed span. It corresponds
   to the last element of the non-reversed span. If the span is empty, the returned
   iterator is equal to rend().

   range-rbegin-rend.svg

.SH Parameters

   \fI(none)\fP

.SH Return value

   Reverse iterator to the first element.

.SH Complexity

   Constant.

.SH Notes

   The underlying iterator of the returned reverse iterator is the end iterator. Hence
   the returned iterator is invalidated if and when the end iterator is invalidated.

.SH Example


// Run this code

 #include <algorithm>
 #include <iostream>
 #include <iterator>
 #include <span>

 int main()
 {
     constexpr std::span<const char> code{"@droNE_T0P_w$s@s#_SECRET_a,p^42!"};

     auto hack = [](const unsigned O) { return O - 0141 < 120; };

     std::copy_if(code.rbegin(), code.rend(),
         std::ostream_iterator<const char>(std::cout), hack);

     std::cout << '\\n';
 }

.SH Output:

 password

.SH See also

   rend    returns a reverse iterator to the end
   crend   \fI(public member function)\fP
   (C++23)
   rbegin  returns a reverse iterator to the beginning of a container or array
   crbegin \fI(function template)\fP
   \fI(C++14)\fP
